// MainWindow.cs created with MonoDevelop
// User: ricko at 11:06 PM 1/2/2009

using System;
using System.Reflection;
using Gtk;
// using Gnome.Url;

public partial class MainWindow: Gtk.Window
{	
	
	private bool isFullscreen;
	
	public MainWindow (): base (Gtk.WindowType.Toplevel)
	{
		isFullscreen = false;
		Build ();
	}
	
	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
	{
		Application.Quit ();
		a.RetVal = true;
	}

	protected virtual void ShowAbout (object sender, System.EventArgs e)
	{
		AboutDialog ad = new AboutDialog();
		Assembly asm = Assembly.GetExecutingAssembly();
		ad.Name = (asm.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0] as AssemblyTitleAttribute).Title;
		ad.Version = asm.GetName().Version.ToString();
		ad.Comments = (asm.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0] as AssemblyDescriptionAttribute).Description;
		ad.Copyright = (asm.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0] as AssemblyCopyrightAttribute).Copyright;
		ad.Authors = authors;
		ad.Website = website;
		ad.LogoIconName = "stock_text_right";
		ad.Icon = this.Icon;
		//Gtk.AboutDialog.SetEmailHook(delegate(Gtk.AboutDialog dialog, string email) {
		//	Gnome.Url.Show("mailto:" + email);
		//});
		//Gtk.AboutDialog.SetUrlHook(delegate(Gtk.AboutDialog dialog, string link) {
		//	Gnome.Url.Show(link);
		//});
		ad.Run();
	}

	protected virtual void OnFullscreenActionActivated (object sender, System.EventArgs e)
	{
		if(!isFullscreen) this.Fullscreen();
		else this.Unfullscreen();
	}

	protected virtual void OnQuitActionActivated (object sender, System.EventArgs e)
	{
		Application.Quit();
	}

	protected virtual void OnWindowStateEvent (object o, Gtk.WindowStateEventArgs args)
	{
		isFullscreen = (args.Event.NewWindowState == Gdk.WindowState.Fullscreen);
		if(isFullscreen) {
			this.FullscreenAction.Label = "Leave Fullscreen";
			this.FullscreenAction.StockId = "gtk-leave-fullscreen";
		}
		else {
			this.FullscreenAction.Label = "Fullscreen";
			this.FullscreenAction.StockId = "gtk-fullscreen";
		}
	}

	protected virtual void OnPropertiesActionActivated (object sender, System.EventArgs e)
	{
		StoryLines.StoryPropertiesWindow prop = new StoryLines.StoryPropertiesWindow();
		prop.Modal = true;
		prop.Show();
	}

	protected virtual void OnPreferencesActionActivated (object sender, System.EventArgs e)
	{
		StoryLines.AppPreferencesWindow pref = new StoryLines.AppPreferencesWindow();
		pref.Modal = true;
		pref.Show();
	}
	
	private static string[] authors = new string[] { "Rick Osborne <rick@rixsoft.com>" };
	private static string website = @"http://rixsoft.com/storylines/";
	
}